home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0292.ZIP / DB3DOC.PRG < prev    next >
Text File  |  1985-09-23  |  5KB  |  153 lines

  1. * DB3DOC.PRG
  2. * Author : Steve Aidikonis - AIDCOM 312/289-2390
  3. * Created: August, 1985
  4. * For dBASE III, this program shows the use of the COPY STRUCTURE EXTENDED
  5. * command.
  6. * This program will help document the data file of your choosing
  7. SET TALK OFF
  8. SET DELIM OFF
  9. CLEAR ALL
  10. CLEAR
  11. * the memvar BIGLOOP is the main loop - Program will keep doing it's
  12. * thing until you tell it to stop or enter an invalid file name
  13. BIGLOOP=.T.
  14. DO WHILE BIGLOOP
  15.   CLEAR
  16.   @ 2,0 SAY "dBASE III Database Document Maker"
  17.   STORE "  A I D C O M      312/289-2390  " TO CMRCL
  18.   @ 4,0 GET CMRCL
  19.   CLEAR GETS
  20.   RELEASE CMRCL
  21.   @ 10,0
  22.   ACCE "Please enter the database name: " TO MFILE
  23.   STORE UPPER(MFILE)+".DBF" TO MFILE
  24.   * look for the .DBF - if it's not there, exit
  25.   IF .NOT. FILE('&MFILE')
  26.     CLEAR
  27.     @ 10,0 SAY "Data file doesn'T EXIST... EXITING."
  28.     CLEAR ALL
  29.     SET DELIM ON
  30.     RETURN
  31.   ENDIF
  32.   USE &MFILE
  33.   * take a look at the file structure before starting
  34.   DISPLAY STRUCTURE
  35.   ?
  36.   ? "====================================="
  37.   ?
  38.   ACCEPT "Press <CR> =====> " TO X
  39.   CLEAR
  40.   MDESCRIP=SPACE(30)
  41.   * memvar MDESCRIP allows for a 30 char. general description of the file.
  42.   @ 5,0 SAY "File Description, &MFILE : " GET MDESCRIP
  43.   READ
  44.   * here's the biggie - STRUCTURE EXTENDED creates a database containing
  45.   * only the names, length, type and decimal spaces for your file
  46.   COPY TO DOCS STRUCTURE EXTENDED
  47.   CLEAR
  48.   USE DOCS
  49.   GO TOP
  50.   @ 1,1 SAY "Data File:"
  51.   @ 1,13 SAY MFILE
  52.   @ 1,33 SAY "File Descrip.:"
  53.   @ 1,49 SAY MDESCRIP
  54.   @ 2,0 SAY "_______________________________________________________"
  55.   @ 2,55 SAY "________________________"
  56.   @ 4,0 SAY "Field No.       Field Name    Type    Width    Dec."
  57.   @ 4,55 SAY "Field Description"
  58.   @ 5,0 SAY "=========       ==========    ====    =====    ===="
  59.   @ 5,55 SAY "========================="
  60.   STORE 6 TO LINE
  61.   STORE 1 TO COUNTER
  62.   * go down the list of field names to allow addition of less terse field
  63.   * descriptions
  64.   DO WHILE .NOT. EOF()
  65.     * set up a blank memvar to store field descriptions
  66.     STORE STR(COUNTER+10,2) TO CSTR
  67.     STORE SPACE(25) TO MFDES&CSTR
  68.     @ LINE,2 SAY STR(COUNTER,2)
  69.     @ LINE,16 SAY FIELD_NAME
  70.     @ LINE,31 SAY FIELD_TYPE
  71.     @ LINE,39 SAY FIELD_LEN
  72.     @ LINE,48 SAY FIELD_DEC
  73.     @ LINE,55 GET MFDES&CSTR
  74.     READ
  75.     CLEAR GETS
  76.     SKIP
  77.     * increment the line and field counters
  78.     LINE=LINE+1
  79.     COUNTER=COUNTER+1
  80.     * if we filled up one screen, clear for another
  81.     IF LINE=24
  82.       @ 6,0 CLEAR
  83.       LINE=6
  84.     ENDIF
  85.   ENDDO
  86.   * end of file? Print it!!
  87.   CLEAR
  88.   ACCEPT "Turn on the printer and press <CR> =======> " TO X
  89.   CLEAR
  90.   @ 10,0 SAY "Printing the documentation for "+MFILE
  91.   GOTO TOP
  92.   SET DEVICE TO PRINT
  93.   COUNTER=1
  94.   HEADING=.T.
  95.   DO WHILE .NOT. EOF()
  96.     IF HEADING
  97.       @ 1,1 SAY "Today's Date:"
  98.       @ 1,16 SAY DATE()
  99.       @ 3,1 SAY "Data File:"
  100.       @ 3,13 SAY MFILE
  101.       @ 3,33 SAY "File Descrip.:"
  102.       @ 3,49 SAY MDESCRIP
  103.       @ 4,0 SAY "_______________________________________________________"
  104.       @ 4,55 SAY "________________________"
  105.       @ 5,0 SAY "Field No.       Field Name    Type    Width    Dec."
  106.       @ 5,55 SAY "Field Description"
  107.       @ 6,0 SAY "=========       ==========    ====    =====    ===="
  108.       @ 6,55 SAY "========================="
  109.       LINE=7
  110.       HEADING=.F.
  111.     ENDIF
  112.     STORE STR(COUNTER+10,2) TO CSTR
  113.     @ LINE,2 SAY STR(COUNTER,2)
  114.     @ LINE,16 SAY FIELD_NAME
  115.     @ LINE,31 SAY FIELD_TYPE
  116.     @ LINE,39 SAY FIELD_LEN
  117.     @ LINE,48 SAY FIELD_DEC
  118.     @ LINE,55 SAY MFDES&CSTR
  119.     SKIP
  120.     STORE LINE+1 TO LINE
  121.     STORE COUNTER+1 TO COUNTER
  122.     IF LINE>56
  123.       HEADING=.T.
  124.     ENDIF
  125.   ENDDO
  126.   STORE LINE+1 TO LINE
  127.   @ LINE,0 SAY "_______________________________________________________"
  128.   @ LINE,55 SAY "________________________"
  129.   SET DEVI TO SCREEN
  130.   USE
  131.   * finished printing, erase the structure file
  132.   ERASE DOCS.DBF
  133.   EJECT
  134.   CLEAR
  135.   * check to see if there are any more files you wish to document
  136.   STORE ' ' TO ANS
  137.   DO WHILE AT(ANS,'YN')=0
  138.     @ 10,0 SAY "Do you wish to document another Database? ===> " ;
  139.     GET ANS PICT '!'
  140.     READ
  141.   ENDDO
  142.   * if not, exit the loop and the program
  143.   IF ANS='N'
  144.     STORE .F. TO BIGLOOP
  145.   ENDIF
  146. ENDDO
  147. @ 10,0
  148. @ 10,0 SAY "THAT'S ALL FOLKS!"
  149. SET DELIM ON
  150. RETURN
  151. ********* END OF FILE
  152. *******************************************************************
  153.